<%@page import="com.wanmait.movies.vo.Pager"%>
<%@page import="com.wanmait.movies.vo.Actor"%>
<%@page import="com.wanmait.movies.vo.Director"%>
<%@page import="com.wanmait.movies.vo.Movie"%>
<%@page import="java.util.ArrayList"%>
<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>搜索</title>
	<script type="text/javascript" src="/movies/js/jquery-3.5.1.min.js"></script>
    <script type="text/javascript">
    	/*
    		搜索页面实现的功能
    			1.显示搜索关键字，比如：狼、排行榜、悬疑片
    			2.列表的形式显示全部符合条件的电影，每页十部(未完成)
    			3.每条电影显示电影照片名字打分时长导演演员信息
    	*/
    </script>
    <style type="text/css">
        body{
            background: #f5f5f5;    
        }
        #first_panel{
            width: 850px;
            margin: 50px auto;
            background: white;
            padding: 50px;
            border-radius: 5px; 
            box-shadow:  0px 0px 5px rgba(0,0,0,0.1);  
        }
        #first_panel #movie_list{
            padding: 0;
            list-style: none;   
        }
        #first_panel .list{
            height: 168px;
            border-bottom: 1px solid #ddd;
            vertical-align: middle;
        }
        
        #first_panel .list .movieimg{
            width: 120px;
            height: 168px;
            float: left;
            vertical-align: middle;
            line-height: 168px;
        }
        #first_panel .list .movieinfo{
            width: 500px;
            height: 100%; 
            float: left;
        }
        #first_panel .list img{
            width: 100px;
            height: 140px;
            overflow: hidden;
        } 
        #first_panel .list .jieshao{
            float: left;
            margin-top: 30px;
            
        }
        #first_panel .point{
            color: orange;
            font-size: 13;
        }
        #first_panel .time{
            font-size: 13;
        }
        #first_panel .mvoiedirector,.movieactor{
            color: gray;
            font-size: 14;
        } 
        a{
        	text-decoration: none;
        }
        #first_panel a:hover{
        	color: red;
        }
        #first_panel #pager{
        	text-align: center;
        }
    </style>	
</head>	
<body>
	<%ArrayList<Movie> movies = (ArrayList<Movie>)request.getAttribute("movies");
	  Pager p = (Pager)request.getAttribute("searchpager");
	  
      String search_text = (String)request.getAttribute("search_text");		 
	%>
	<jsp:include page="/include/head.jsp"></jsp:include>
	<jsp:include page="/include/neck.jsp"></jsp:include>
	<div id="first_panel">
        <h1>查询"<%=search_text %>"结果</h1>
        <ul id="movie_list">
        <%
        if(movies == null){
        	%><li>无查询结果</li><%
        }else{
        	for(Movie m: movies){
        	%>
        	<li class="list">
                <div class="movieimg">
                    <a href="javascript:"><img src="/movies/images/<%=m.getMovieImage()%>"></a>
                </div>
                <div class="jieshao">
                 <a href="/movies/MoviesServlet?action=showovies&movieId=<%=m.getId()%>" class="moviename"><%=m.getMovieName() %></a><br>
                 <a class="point"><%=m.getMovieGrades() %>分</a>
                 <a class="time">片长:<%=m.getMovieTime() %>分钟</a><br>
                 
                 <%
                 for(Director d: m.getDirectorList()){
                	 if(d.getDirectorName() != null){
                		 %>
                    	 <a class="mvoiedirector" href="/movies/MoviesServlet?action=findMovieByDirector&id=<%=d.getId()%>"><%=d.getDirectorName() %></a>/
                    	 <%
                	 }
                 }
                 %>
                 
                 
				 <%
                 for(Actor a: m.getActorList()){
                	 if(a.getActorName() != null){
                	 %>
                	 <a class="movieactor"  href="/movies/MoviesServlet?action=findMovieByActor&id=<%=a.getId()%>"><%=a.getActorName() %> </a>/
                	 <%
                	 }
                 }
                 %>
				
                </div>  
            </li>
        	<% 
        	
        }} %>
            
                 
        </ul>
        <div id="pager">
        <%
        	String str = request.getQueryString();//拿到?后面的字符串
            str = str.substring(0, str.length()-1);
        	for(int i = 1; i <= p.getCountinPager(); i++){
        		
		        %>[<a href="/movies/SearchServlet?<%=str+i%>" onclick="return <%=request.getAttribute("ifpageuse")%>"><%=i%></a>]<%        		
        	} 
        
        %>
     	</div>
    </div>
</body>
</html>